home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume5 / uemacs3 < prev    next >
Encoding:
Text File  |  1986-11-30  |  48.2 KB  |  1,918 lines

  1. Newsgroups: mod.sources
  2. Subject: MicroEMACS version 30 updates.
  3. Approved: jpn@panda.UUCP
  4.  
  5. Mod.sources:  Volume 5, Issue 1
  6.  
  7. Here are three reader submitted updates to the MicroEMACS version 30
  8. recently submitted to mod.sources.  I have not tested them.  I hope
  9. you find them useful.
  10.  
  11. John P. Nelson, Moderator, mod.sources
  12. (decvax!genrad!panda!jpn  seismo!harvard!wjh12!panda!jpn)
  13. Send source code to panda!sources, requests to panda!sources-request
  14.  
  15. ----------------------------------------------------------------------
  16. Today's Topics:
  17.                 file-insert command for microEmacs 30
  18.                 Fix for termcap upgrade to MicroEmacs
  19.           GNU compatability, System V and PC7300 MicroEMACS.
  20. ----------------------------------------------------------------------
  21.  
  22. From: genrad!decvax!yetti!oz (Ozan Yigit)
  23. Subject: file-insert command for microEmacs 30
  24.  
  25. The following shar file contains the diffs to symbol.c and
  26. a new file misc.c that contains the necessary code to do a
  27. file-insert in microEmacs (the definitive version 30).
  28.  
  29. Currently the symbol.c binds the keys C-X C-I to this function,
  30. which is compatible with Goslings, but not necessarily with GNU.
  31. I have not yet heard anything from David Conroy about this addition
  32. [I desperately needed this facility..] or any alternatives to it. So,
  33. here it is. Enjoy.
  34.  
  35. oZ
  36. -------------------- SNAP HERE ----------------------------------
  37. #!/bin/sh
  38. # This is a shell archive, meaning:
  39. # 1. Remove everything above the #!/bin/sh line.
  40. # 2. Save the resulting text in a file.
  41. # 3. Execute the file with /bin/sh (not csh) to create the files:
  42. #    symbol.DIFFS
  43. #    misc.c
  44. # This archive created: Thu May 15 20:52:47 1986
  45. export PATH; PATH=/bin:$PATH
  46. echo shar: extracting "'symbol.DIFFS'" '(189 characters)'
  47. if test -f 'symbol.DIFFS'
  48. then
  49.     echo shar: over-writing existing file "'symbol.DIFFS'"
  50. fi
  51. sed 's/^X//' << \SHAR_EOF > 'symbol.DIFFS'
  52. X99a100,104
  53. X>  * Defined by "misc.c".
  54. X>  */
  55. X> extern    int    fileinsert();        /* Insert contents of a file    */
  56. X> 
  57. X> /*
  58. X189a195,197
  59. X> #if    MISC
  60. X>     KCTLX|KCTRL|'I',fileinsert,    "file-insert",
  61. X> #endif
  62. SHAR_EOF
  63. if test 189 -ne "`wc -c 'symbol.DIFFS'`"
  64. then
  65.     echo shar: error transmitting "'symbol.DIFFS'" '(should have been 189 characters)'
  66. fi
  67. echo shar: extracting "'misc.c'" '(1644 characters)'
  68. if test -f 'misc.c'
  69. then
  70.     echo shar: over-writing existing file "'misc.c'"
  71. fi
  72. sed 's/^X//' << \SHAR_EOF > 'misc.c'
  73. X/*
  74. X * Name:    MicroEMACS
  75. X *        Miscellaneous extensions
  76. X * Version:    30+
  77. X * Last edit:    30-Apr-86
  78. X * By:        oz
  79. X *        decvax!utzoo!yetti!oz
  80. X */
  81. X#include    "def.h"
  82. X
  83. X/*
  84. X * Insert a file at the dot a la yank. This is not
  85. X * terribly difficult. Insert routines handle
  86. X * it all. All we have to do is to ask for a
  87. X * filename, make sure it exists, and loop through
  88. X * the entire file. Just like yank, we try to
  89. X * handle the cosmetic bug, so that when entire
  90. X * text lands off screen, we will not look silly.
  91. X * This is usually bound to C-X C-I.
  92. X */
  93. Xfileinsert(f, n, k)
  94. X{
  95. X    register int     s;
  96. X    register char    *p;
  97. X    register LINE    *lp;
  98. X    char        fname[NFILEN];
  99. X    char        line[NLINE];
  100. X    register int    nline;
  101. X
  102. X    if ((s=ereply("Insert file: ", fname, NFILEN)) != TRUE)
  103. X        return (s);
  104. X    adjustcase(fname);
  105. X    if ((s=ffropen(fname)) == FIOFNF) {    /* hard file open    */
  106. X        if (kbdmop == NULL)
  107. X            eprintf("Cannot open %s", fname);
  108. X        return(FALSE);
  109. X    }
  110. X    nline = 0;                /* newline counting..    */
  111. X    while ((s=ffgetline(line, NLINE)) == FIOSUC) {
  112. X        for (p = line; *p; p++)
  113. X            if (linsert(1, *p) == FALSE)
  114. X                return(FALSE);
  115. X                        /* eol: fake newline..    */
  116. X        if(newline(FALSE, 1, KRANDOM) == FALSE)
  117. X            return(FALSE);
  118. X        ++nline;
  119. X    }
  120. X    ffclose();                /* ignore errors here    */
  121. X    if (s==FIOEOF && kbdmop==NULL) {    /* do not zap anything  */
  122. X        if (nline == 1)
  123. X            eprintf("[Inserted 1 line]");
  124. X        else
  125. X            eprintf("[Inserted %d lines]", nline);
  126. X    }
  127. X    lp = curwp->w_linep;            /* Cosmetic adjustment    */
  128. X    if (curwp->w_dotp == lp) {        /* if offscreen insert.    */
  129. X        while (nline-- && lback(lp)!=curbp->b_linep)
  130. X            lp = lback(lp);
  131. X        curwp->w_linep = lp;        /* Adjust framing.    */
  132. X        curwp->w_flag |= WFHARD;
  133. X    }
  134. X    return (TRUE);
  135. X}
  136. SHAR_EOF
  137. if test 1644 -ne "`wc -c 'misc.c'`"
  138. then
  139.     echo shar: error transmitting "'misc.c'" '(should have been 1644 characters)'
  140. fi
  141. #    End of shell archive
  142. exit 0
  143.  
  144. ------------------------------
  145.  
  146. From: talcott!ima!amdcad!jimb (Jim Budler)
  147. Subject: Fix for termcap upgrade to MicroEmacs
  148. Reply-To: jimb@amdcad.UUCP (Jim Budler)
  149. Organization: AMD, Sunnyvale, California
  150.  
  151. The patch as posted leaves the terminal in a strange mode when
  152. there is an exit(1) for any of the bad termcap errors, such as
  153. "This terminal is too dumb", etc.
  154. I patched in calls to the existing ttclose() routine from ttyio.c.
  155. Works fine. Use patch to apply to ../uemacs/tty/termcap/tty.c
  156.  
  157. *** /tmp/,RCSt1016739    Fri Apr 25 23:10:53 1986
  158. --- tty.c    Fri Apr 25 23:09:31 1986
  159. ***************
  160. *** 66,71
  161.           if ((tv_stype = getenv("TERM")) == NULL)
  162.           {
  163.                   puts("Environment variable TERM not defined!");
  164.                   exit(1);
  165.           }
  166.   
  167.  
  168. --- 66,72 -----
  169.           if ((tv_stype = getenv("TERM")) == NULL)
  170.           {
  171.                   puts("Environment variable TERM not defined!");
  172. +         ttclose();
  173.                   exit(1);
  174.           }
  175.   
  176. ***************
  177. *** 73,78
  178.           {
  179.                   sprintf(err_str, "Unknown terminal type %s!", tv_stype);
  180.                   puts(err_str);
  181.                   exit(1);
  182.           }
  183.   
  184.  
  185. --- 74,80 -----
  186.           {
  187.                   sprintf(err_str, "Unknown terminal type %s!", tv_stype);
  188.                   puts(err_str);
  189. +         ttclose();
  190.                   exit(1);
  191.           }
  192.   
  193. ***************
  194. *** 99,104
  195.           if(CD == NULL || CM == NULL || CE == NULL || UP == NULL)
  196.           {
  197.                   puts("This terminal is not powerful enough to run Micro Emacs\n");
  198.                   exit(1);
  199.           }
  200.       if (!*CE) {
  201.  
  202. --- 101,107 -----
  203.           if(CD == NULL || CM == NULL || CE == NULL || UP == NULL)
  204.           {
  205.                   puts("This terminal is not powerful enough to run Micro Emacs\n");
  206. +         ttclose();
  207.                   exit(1);
  208.           }
  209.       if (!*CE) {
  210. ***************
  211. *** 122,127
  212.           if (p >= &tcapbuf[TCAPSLEN])
  213.           {
  214.                   puts("Terminal description too big!\n");
  215.                   exit(1);
  216.           }
  217.       if (*TI) tputs (TI);    /* init the term */
  218.  
  219. --- 125,131 -----
  220.           if (p >= &tcapbuf[TCAPSLEN])
  221.           {
  222.                   puts("Terminal description too big!\n");
  223. +         ttclose();
  224.                   exit(1);
  225.           }
  226.       if (*TI) tputs (TI);    /* init the term */
  227.  
  228. ------------------------------
  229.  
  230. Date: Sat, 26 Apr 86 02:47:32 pst
  231. From: rtech.rtech!condor!daveb (Dave Brower)
  232. Subject: GNU compatability, System V and PC7300 MicroEMACS.
  233.  
  234. Enclosed are replacement and new files for the MicroEMACS recently sent
  235. over mod.sources.  They provide GNU Emacs command compatibility, System
  236. V support, and some hacks for PC7300 display dame bramage.  More details
  237. are in the GNU_README file.
  238.  
  239. #! /bin/sh
  240. # This is a shell archive, meaning:
  241. # 1. Remove everything above the #! /bin/sh line.
  242. # 2. Save the resulting text in a file.
  243. # 3. Execute the file with /bin/sh (not csh) to create the files:
  244. #    GNU_README
  245. #    gnucmds.c
  246. #    gnusymbol.c
  247. #    sys
  248. #    tty
  249. # This archive created: Sat Apr 26 02:34:55 1986
  250. export PATH; PATH=/bin:$PATH
  251. if test -f 'GNU_README'
  252. then
  253.     echo shar: will not over-write existing file "'GNU_README'"
  254. else
  255. cat << \SHAR_EOF > 'GNU_README'
  256. This archive contains a number of files to be used with the recent
  257. mod.sources posting of Dave Conroy's MicroEMACS.  The new files support
  258. these new features:
  259.  
  260.     * GNU Emacs compatibility
  261.  
  262.     * System V.
  263.  
  264.     * AT&T UNIX PC 7300/3b1.
  265.  
  266.  
  267.   The GNU emacs compatibility is as the crudest possible level, a simple
  268. remapping of existing commands, and a few new ones I couldn't live
  269. without.  Further work is planned, but this should be enough to  help
  270. most people out immediately.  The file gnusymbol.c replaces the
  271. previously distributed symbol.c, and the file gnucmds.c contains my
  272. additions.  You will need to change the contents in the OBJS macro of
  273. your Makefile, or your build scripts on other systems.
  274.  
  275.   System V is supported in the obvious way with the addition of a new
  276. sys/sysv directory.  The ttyio.c and spawn.c files have been further
  277. decoupled by using reentrant calls to ttopen and ttclose instead of
  278. sharing the termio structures.
  279.  
  280.   My PC7300 wouldn't work right with the ansi terminal driver because
  281. the scroll region and index/reverse index commands don't appear to work
  282. as needed.  I've reimplemented the insert and delete block operations
  283. using the insert and delete line capabilities.  Not surprisingly, the
  284. vt220 function keys didn't work right, so I threw all the code out. 
  285. Being a "real" Emacs fan, I chucked the arrow keys too.
  286.  
  287.                             ----------------
  288.  
  289. There is a continuing discussion of MicroEMACS and GNU compatibility in
  290. net.emacs.  I am attempting to put together a mailing list of people who
  291. are interested in actively pursuing this goal, with intent to make
  292. regular mod.source submissions as progress is made.
  293.  
  294. The first step was to get this short term fix distributed.  The next is
  295. to try to merge some of the variant versions that are floating around to
  296. grab missing features.  For instance, the MicroEMACS 3.5 posted in
  297. net.sources recently has word wrap, but doesn't have reverse video
  298. modelines or the smart redisplay algorithm.
  299.  
  300. If you are interested in working on this project, send me mail at:
  301.  
  302.                {sun, amdahl, mtxinu, cbosgd}!rtech!daveb
  303.  
  304. Compatibility now for the future!
  305.  
  306.  
  307. SHAR_EOF
  308. chmod +x 'GNU_README'
  309. fi # end of overwriting check
  310. if test -f 'gnucmds.c'
  311. then
  312.     echo shar: will not over-write existing file "'gnucmds.c'"
  313. else
  314. cat << \SHAR_EOF > 'gnucmds.c'
  315. /*
  316.  * Name:    MicroEMACS
  317.  *        GNU compatible commands
  318.  * Version:    29
  319.  * Last edit:    19-Apr-86
  320.  * By:        {sun, amdahl, mtxinu}!rtech!daveb
  321.  *
  322.  * This file contains new commands written for GNU emacs compatibility.
  323.  *
  324.  *    suspend(),        replacing jeffexit().
  325.  *    savebuffs(),        new.
  326.  *    savequit(),        new.
  327.  *    notmodified(),        new.
  328.  *    findalternate(),    new.
  329.  *    scrollother(),        new.
  330.  */
  331. #include    "def.h"
  332.  
  333. /*
  334.  * GNU style suspend.  Asks to save all dirty buffs, then starts a CLI.
  335.  * Bound to "C-Z" and "X-C-Z"
  336.  *
  337.  * Supercedes "jeffexit"    X-C-Z too.
  338.  */
  339. suspend(f, n, k)
  340. {
  341.     if(ABORT != savebuffs(0, 0, KRANDOM))
  342.         return (spawncli(f, n, KRANDOM));
  343.     else
  344.         return (ABORT);
  345. }
  346.  
  347. /*
  348.  * GNU compatible buffer save routine.
  349.  * Scan all buffers and ask for disposition.
  350.  * Does not affect display.    X-S
  351.  * (daveb)
  352.  */
  353. savebuffs(f, n, k)
  354. {
  355.     char        buf[ 80 ];
  356.     register int    s;
  357.     register    BUFFER *bp;
  358.     BUFFER        *oldbp = curbp;
  359.     int        considered = FALSE;
  360.     int        row = ttrow;
  361.     int        col = ttcol;
  362.  
  363.     for( bp = bheadp; bp != NULL; bp = bp->b_bufp )
  364.         if (bp->b_bname[0]!=' ' && bp->b_fname[0]!='\0' 
  365.             && (bp->b_flag&BFCHG) != 0) {
  366.             considered = TRUE;
  367.             strcpy( buf, "Save file ");
  368.             strcat( buf, bp->b_fname );
  369.             s = eyesno( buf, bp->b_fname);
  370.             if (s == ABORT)
  371.                 return (ABORT);
  372.             if (s == TRUE) {
  373.                 curbp = bp;
  374.                 filesave(f, n, KRANDOM);
  375.                 ttmove( row, col );
  376.                 ttflush();
  377.             }
  378.         }
  379.     if(!considered)
  380.         eprintf("(No files need saving)");
  381.     curbp = oldbp;
  382.     ttmove( row, col );
  383.     ttflush();
  384.     return(TRUE);
  385. }
  386.  
  387. /*
  388.  * GNU style exit:  query on every dirty buffer, then exit.  X-C-C
  389.  */
  390. savequit(f, n, k)
  391. {
  392.     if(ABORT != savebuffs(0, 0, KRANDOM))
  393.         quit(f, n, k);
  394.     return( ABORT );
  395. }
  396.  
  397. /*
  398.  * Turn off the dirty bit on this buffer.  M-~
  399.  */
  400. notmodified(f, n, k)
  401. {
  402.     register WINDOW *wp;
  403.     
  404.     curbp->b_flag &= ~BFCHG;
  405.     wp = wheadp;                /* Update mode lines.    */
  406.     while (wp != NULL) {
  407.         if (wp->w_bufp == curbp)
  408.             wp->w_flag |= WFMODE;
  409.         wp = wp->w_wndp;
  410.     }
  411.     eprintf("Modification-flag cleared");
  412.     return (TRUE);
  413. }
  414.  
  415. /*
  416.  * Scroll the other window.  On C-M-V.  Works OK (daveb).
  417.  */
  418. scrollother(f, n, k)
  419. {
  420.     nextwind(0, 0, KRANDOM);
  421.     forwpage(f, n, k);
  422.     prevwind(0, 0, KRANDOM);
  423. }
  424.  
  425. SHAR_EOF
  426. chmod +x 'gnucmds.c'
  427. fi # end of overwriting check
  428. if test -f 'gnusymbol.c'
  429. then
  430.     echo shar: will not over-write existing file "'gnusymbol.c'"
  431. else
  432. cat << \SHAR_EOF > 'gnusymbol.c'
  433. /*
  434.  * Name:    MicroEMACS
  435.  *        Symbol table stuff for GNU emacs compatability
  436.  * Version:    29
  437.  * Last edit:    19-Apr-86
  438.  * By:        {sun, amdahl, cbosgd}!rtech!gonzo!daveb
  439.  *
  440.  * Symbol tables, and keymap setup.
  441.  * The terminal specific parts of building the
  442.  * keymap has been moved to a better place.
  443.  *
  444.  * This version matches the standard GNU Emacs 17.49 bindings.
  445.  * With this file, MicroEMACS is a proper subset of GNU.
  446.  *
  447.  * If a GNU feature was misnamed, it was moved.
  448.  * If a GNU feature was "nearly" right, it was noted for later work.
  449.  * If a MicroEMACS feature was incompatible, it was dropped.
  450.  *
  451.  * Compatibility NOW for the future!
  452.  */
  453. #include    "def.h"
  454.  
  455. #define    DIRLIST    0            /* Disarmed!            */
  456.  
  457. # define    DEL    0x7f
  458. # define    ESC    0x1b
  459.  
  460. /* # define DAVEB    *//* Dave Brower specials, not GNU compatibility */
  461.  
  462. /*
  463.  * Defined by "main.c".
  464.  */
  465. extern    int    ctrlg();        /* Abort out of things        */
  466. extern    int    quit();            /* Rude Quit            */
  467. extern    int    ctlxlp();        /* Begin macro            */
  468. extern    int    ctlxrp();        /* End macro            */
  469. extern    int    ctlxe();        /* Execute macro        */
  470. extern  int    showversion();        /* Show version numbers, etc.    */
  471.  
  472. /*
  473.  * defined by "gnucmds.c"
  474.  */
  475. extern    int    savebuffs();        /* GNU style save-some-buffers    */
  476. extern    int    savequit();        /* GNU save-buffers-kill-emacs    */
  477. extern    int    suspend();        /* GNU style suspend        */
  478. extern    int    notmodified();        /* GNU make buffer undirty    */
  479. extern    int    scrollother();        /* GNU scroll other window    */
  480.  
  481. /*
  482.  * Defined by "search.c".
  483.  */
  484. extern    int    forwsearch();        /* Search forward        */
  485. extern    int    backsearch();        /* Search backwards        */
  486. extern  int    searchagain();        /* Repeat last search command    */
  487. extern  int    forwisearch();        /* Incremental search forward    */
  488. extern  int    backisearch();        /* Incremental search backwards    */
  489. extern  int    queryrepl();        /* Query replace        */
  490.  
  491. /*
  492.  * Defined by "basic.c".
  493.  */
  494. extern    int    gotobol();        /* Move to start of line    */
  495. extern    int    backchar();        /* Move backward by characters    */
  496. extern    int    gotoeol();        /* Move to end of line        */
  497. extern    int    forwchar();        /* Move forward by characters    */
  498. extern    int    gotobob();        /* Move to start of buffer    */
  499. extern    int    gotoeob();        /* Move to end of buffer    */
  500. extern    int    forwline();        /* Move forward by lines    */
  501. extern    int    backline();        /* Move backward by lines    */
  502. extern    int    forwpage();        /* Move forward by pages    */
  503. extern    int    backpage();        /* Move backward by pages    */
  504. extern    int    setmark();        /* Set mark            */
  505. extern    int    swapmark();        /* Swap "." and mark        */
  506. extern    int    gotoline();        /* Go to a specified line.    */
  507.  
  508. /*
  509.  * Defined by "buffer.c".
  510.  */
  511. extern    int    listbuffers();        /* Display list of buffers    */
  512. extern    int    usebuffer();        /* Switch a window to a buffer    */
  513. extern    int    killbuffer();        /* Make a buffer go away.    */
  514.  
  515. #if    DIRLIST
  516. /*
  517.  * Defined by "dirlist.c".
  518.  */
  519. extern    int    dirlist();        /* Directory list.        */
  520. #endif
  521.  
  522. /*
  523.  * Defined by "file.c".
  524.  */
  525. extern    int    fileread();        /* Get a file, read only    */
  526. extern    int    filevisit();        /* Get a file, read write    */
  527. extern    int    filewrite();        /* Write a file            */
  528. extern    int    filesave();        /* Save current file        */
  529. extern    int    filename();        /* Adjust file name        */
  530.  
  531. /*
  532.  * Defined by "random.c".
  533.  */
  534. extern    int    selfinsert();        /* Insert character        */
  535. extern    int    showcpos();        /* Show the cursor position    */
  536. extern    int    twiddle();        /* Twiddle characters        */
  537. extern    int    quote();        /* Insert literal        */
  538. extern    int    openline();        /* Open up a blank line        */
  539. extern    int    newline();        /* Insert CR-LF            */
  540. extern    int    deblank();        /* Delete blank lines        */
  541. extern    int    indent();        /* Insert CR-LF, then indent    */
  542. extern    int    forwdel();        /* Forward delete        */
  543. extern    int    backdel();        /* Backward delete        */
  544. extern    int    killline();        /* Kill forward            */
  545. extern    int    yank();            /* Yank back from killbuffer.    */
  546.  
  547. /*
  548.  * Defined by "region.c".
  549.  */
  550. extern    int    killregion();        /* Kill region.            */
  551. extern    int    copyregion();        /* Copy region to kill buffer.    */
  552. extern    int    lowerregion();        /* Lower case region.        */
  553. extern    int    upperregion();        /* Upper case region.        */
  554.  
  555. /*
  556.  * Defined by "spawn.c".
  557.  */
  558. extern    int    spawncli();        /* Run CLI in a subjob.        */
  559.  
  560. /*
  561.  * Defined by "window.c".
  562.  */
  563. extern    int    reposition();        /* Reposition window        */
  564. extern    int    refresh();        /* Refresh the screen        */
  565. extern    int    nextwind();        /* Move to the next window    */
  566. extern  int    prevwind();        /* Move to the previous window    */
  567. extern    int    mvdnwind();        /* Move window down        */
  568. extern    int    mvupwind();        /* Move window up        */
  569. extern    int    onlywind();        /* Make current window only one    */
  570. extern    int    splitwind();        /* Split current window        */
  571. extern    int    enlargewind();        /* Enlarge display window.    */
  572. extern    int    shrinkwind();        /* Shrink window.        */
  573.  
  574. /*
  575.  * Defined by "word.c".
  576.  */
  577. extern    int    backword();        /* Backup by words        */
  578. extern    int    forwword();        /* Advance by words        */
  579. extern    int    upperword();        /* Upper case word.        */
  580. extern    int    lowerword();        /* Lower case word.        */
  581. extern    int    capword();        /* Initial capitalize word.    */
  582. extern    int    delfword();        /* Delete forward word.        */
  583. extern    int    delbword();        /* Delete backward word.    */
  584.  
  585. /*
  586.  * Defined by "extend.c".
  587.  */
  588. extern    int    extend();        /* Extended commands.        */
  589. extern    int    help();            /* Help key.            */
  590. extern    int    bindtokey();        /* Modify key bindings.        */
  591. extern    int    wallchart();        /* Make wall chart.        */
  592.  
  593. typedef    struct    {
  594.     short    k_key;            /* Key to bind.            */
  595.     int    (*k_funcp)();        /* Function.            */
  596.     char    *k_name;        /* Function name string.    */
  597. }    KEY;
  598.  
  599. /*
  600.  * Default key binding table. This contains
  601.  * the function names, the symbol table name, and (possibly)
  602.  * a key binding for the builtin functions. There are no
  603.  * bindings for C-U or C-X. These are done with special
  604.  * code, but should be done normally.
  605.  */
  606.  
  607. /* GNU standard bindings that are missing are commented out with the
  608.  * following notations:
  609.  *
  610.  *    /*B    Braindamaged in current implementation.
  611.  *    /*D    Design restructuring is needed.
  612.  *    /*E    Easy, a few hours.
  613.  *    /*H    Hard, (days) but possible if desirable.
  614.  *    /*I    Impossible (weeks), much too hard to do right.
  615.  *    /*M    Moderate difficulty, a day or so.
  616.  *    /*T    On the to do list.
  617.  *    /*U    Undecided.
  618.  *    /*X    Means unnecessary to do.
  619.  *    /*W    Current version is wrong.
  620.  *
  621.  *   Well, braindamaged is a bit too strong, but doing all the argument
  622.  *   processing in the main loop, and not having meta- ancd ctrl-x
  623.  *   be bindable commands seems kinda funny to me (daveb).
  624.  */
  625.  
  626. KEY    key[] = {
  627.     KCTRL|'@',    setmark,    "set-mark-command",
  628.     KCTRL|'A',    gotobol,    "beginning-of-line",
  629.     KCTRL|'B',    backchar,    "backward-char",
  630. /*DHX    KCTRL|'C',    ???,        "mode-specific-command-prefix",    */
  631.     KCTRL|'D',    forwdel,    "delete-char",
  632.     KCTRL|'E',    gotoeol,    "end-of-line",
  633.     KCTRL|'F',    forwchar,    "forward-char",
  634.     KCTRL|'G',    ctrlg,        "keyboard-quit",
  635.     KCTRL|'H',    help,        "help-command",
  636. /*DHX    KCTRL|'I',    ???,        "indent-for-tab-command",    */
  637.     KCTRL|'J',    indent,        "newline-and-indent",
  638.     KCTRL|'K',    killline,    "kill-line",
  639.     KCTRL|'L',    refresh,    "recenter",
  640.             /*W actually doesn't recenter...        */
  641.  
  642.     KCTRL|'M',    newline,    "newline",
  643.     KCTRL|'N',    forwline,    "next-line",
  644.     KCTRL|'O',    openline,    "open-line",
  645.     KCTRL|'P',    backline,    "previous-line",
  646.     KCTRL|'Q',    quote,        "quoted-insert",
  647.     KCTRL|'R',    backisearch,    "isearch-backward",
  648.     KCTRL|'S',    forwisearch,    "isearch-forward",
  649.     KCTRL|'T',    twiddle,    "transpose-characters",
  650. /*BMT    KCTRL|'U',    ???,        "universal-argument,"        */
  651.     KCTRL|'V',    forwpage,    "scroll-up",
  652.     KCTRL|'W',    killregion,    "kill-region",
  653. /*BMT    KCTRL|'X',    ???,        "Control-X-prefix",        */
  654.     KCTRL|'Y',    yank,        "yank",
  655.             /*WET doesn't set point! */
  656.  
  657.     KCTRL|'Z',    suspend,    "suspend-emacs",
  658.  
  659. /*BMT    KMETA,        ???,        "ESC-prefix",            */
  660. /*DX    KCTRL|']',    ???,        "abort-recursive-edit",        */
  661. /*DIX    KCTRL|'_',    ???,        "undo",                */
  662.  
  663.     DEL,        backdel,    "delete-backward-char",
  664.  
  665. /*DIX    KCTLX|KCTRL|'A',???,        "add-mode-abbrev",        */
  666.     KCTLX|KCTRL|'B',listbuffers,    "list-buffers",
  667.     KCTLX|KCTRL|'C',savequit,    "save-buffers-kill-emacs",
  668.  
  669. #if    DIRLIST
  670.     KCTLX|KCTRL|'D',dirlist,    "list-directory",
  671. #endif
  672.  
  673. /*DIX    KCTLX|KCTRL|'E',???,        "eval-last-sexp",        */
  674.     KCTLX|KCTRL|'F',filevisit,    "find-file",
  675. /*DIX    KCTLX|KCTRL|'H',???,        "inverse-add-mode=abbrev",    */
  676. /*MT    KCTLX|KCTRL|'I',???,        "indent-rigidly",        */
  677.     KCTLX|KCTRL|'L',lowerregion,    "downcase-region",
  678. /*ET    KCTLX|KCTRL|'N', ???,        "set-goal-column"        */
  679.     KCTLX|KCTRL|'O',deblank,    "delete-blank-lines",
  680. /*MU    KCTLX|KCTRL|'P',???,        "mark-page"             */
  681.      KCTLX|KCTRL|'R',fileread,    "file-file-read-only",
  682.                 /*WU incorrect behaviour...        */
  683.     KCTLX|KCTRL|'S',filesave,    "file-buffer",
  684.  
  685. /*EU    KCTLX|KCTRL|'T',???,        "transpose-lines",        */
  686.     KCTLX|KCTRL|'U',upperregion,    "upcase-region",
  687. /*EU    KCTLX|KCTRL|'V',findalternate,    "find-alternate-file",        */
  688.     KCTLX|KCTRL|'W',filewrite,    "write-file",
  689.     KCTLX|KCTRL|'X',swapmark,    "exchange-point-and-mark",
  690.     KCTLX|KCTRL|'Z',spawncli,    "suspend-emacs",
  691.  
  692. /*MT    KCTLX|ESC    ???,        "repeat-complex-command",    */
  693. /*U    KCTLX|'$'    ???,        "set-selective-display",    */
  694.     KCTLX|'(',    ctlxlp,        "start-kbd-macro",
  695.     KCTLX|')',    ctlxrp,        "end-kbd-macro",
  696. /*DIX    KCTLX|'+',    ???,        "add-global-abbrev",        */
  697. /*DIX    KCTLX|'-',    ???,        "inverse-add-global-abbrev",    */
  698. /*MX    KCTLX|'.',    ???,        "set-fill-prefix",        */
  699. /*HX    KCTLX|'/',    ???,        "point-to-register",        */
  700. /*MT    KCTLX|'0',    ???,        "delete-window",        */
  701.     KCTLX|'1',    onlywind,    "delete-other-windows",
  702.     KCTLX|'2',    splitwind,    "split-window-vertically",
  703. /*MX    KCTLX|'4',    ???,        "ctl-x-4-prefix",        */
  704. /*DHX    KCTLX|'5',    ???,        "split-window-horizontally",    */
  705. /*EX    KCTLX|';',    ???,        "set-comment-column",        */
  706. /*HU    KCTLX|'<',    ???,        "scroll-left",            */
  707.     KCTLX|'=',    showcpos,    "what-cursor-position",
  708. /*HU    KCTLX|'>',    ???,        "scroll-right",            */
  709. /*MU    KCTLX|'[',    ???,        "backward-page",        */
  710. /*MU    KCTLX|']',    ???,        "forward-page",            */
  711.     KCTLX|'^',    enlargewind,    "enlarge-window",
  712. /*HX    KCTLX|'`',    ???,        "next-error",            */
  713. /*MU    KCTLX|'A',    ???,        "append-to-buffer",        */
  714.     KCTLX|'B',    usebuffer,    "switch-to-buffer",
  715. /*MX    KCTLX|'D',    ???,        "dired",            */
  716.     KCTLX|'E',    ctlxe,        "call-last-kbd-macro",
  717. /*EU    KCTLX|'F',    ctlxe,        "set-fill-column",        */
  718. /*HX    KCTLX|'G',    ???,        "insert-register",        */
  719. /*EU    KCTLX|'H',    ???,        "mark-whole-buffer",        */
  720. /*MU    KCTLX|'I',    ???,        "insert-file",            */
  721. /*HX    KCTLX|'J',    ???,        "register-to-point",        */
  722.     KCTLX|'K',    killbuffer,    "kill-buffer",
  723. /*MU    KCTLX|'L',    ???,        "count-lines-page",        */
  724. /*HU    KCTLX|'N',    ???,        "narrow-to-region",        */
  725.     KCTLX|'O',    nextwind,    "other-window",
  726. /*HU    KCTLX|'P',    ???,        "narrow-to-page",        */
  727. /*MX    KCTLX|'Q',    ???,        "kbd-macro-qry",        */
  728. /*HX    KCTLX|'R',    ???,        "copy-rectangle-to-register",    */
  729.     KCTLX|'S',    savebuffs,    "save-some-buffers",
  730. /*HX    KCTLX|'U',    ???,        "advertised-undo",        */
  731. /*HX    KCTLX|'W',    ???,        "widen",            */
  732. /*HX    KCTLX|'{',    ???,        "shrink-window-horizontally",    */
  733. /*HX    KCTLX|'}',    ???,        "enlarge-window-horizontally",    */
  734. /*MT    KCTLX|DEL,    ???,        "backward-kill-sentence,"    */
  735.  
  736. /*MU    KMETA|KCTRL|'@',???,        "mark-sexp",            */
  737. /*MU    KMETA|KCTRL|'A',???,        "beginning-of-defun",        */
  738. /*MU    KMETA|KCTRL|'B',???,        "backwards-sexp",        */
  739. /*MX    KMETA|KCTRL|'C',???,        "exit-recursive-edit",        */
  740. /*MU    KMETA|KCTRL|'D',???,        "down-list",            */
  741. /*MU    KMETA|KCTRL|'E',???,        "end-of-defun",            */
  742. /*MU    KMETA|KCTRL|'F',???,        "forward-sexp",            */
  743. /*MU    KMETA|KCTRL|'H',???,        "mark-defun",            */
  744. /*MU    KMETA|KCTRL|'J',???,        "indent-new-comment-line",    */
  745. /*MU    KMETA|KCTRL|'K',???,        "kill-sexp",            */
  746. /*MU    KMETA|KCTRL|'N',???,        "foward-list",            */
  747. /*EU    KMETA|KCTRL|'O',???,        "split-line",            */
  748. /*MU    KMETA|KCTRL|'P',???,        "backward-list",        */
  749. /*HX    KMETA|KCTRL|'S',???,        "isearch-forward-regexp",    */
  750. /*MU    KMETA|KCTRL|'T',???,        "transpose-sexps",        */
  751. /*MU    KMETA|KCTRL|'U',???,        "backward-up-list",        */
  752.     KMETA|KCTRL|'V',scrollother,    "scroll-other-window",
  753. /*ET    KMETA|KCTRL|'W',???,        "append-next-kill",        */
  754.  
  755. /*IX    KMETA|ESC,    ???        "eval-expression",        */
  756. /*IX    KMETA|CTRL|'\',    ???        "indent-region",        */
  757. /*MU    KMETA|' ',    ???        "just-one-space",        */
  758. /*HT    KMETA|'!',    ???,        "shell-command", */
  759. /*HU    KMETA|'$',    ???,        "spell-word", */
  760.     KMETA|'%',    queryrepl,    "query-replace",
  761. /*IX    KMETA|'\'',    ???,        "abbrev-prefix-mark",        */
  762. /*TU    KMETA|'(',    ???,        "insert-parenthesis", */
  763. /*HU    KMETA|')',    ???,        "move-past-close-and-reindent", */
  764. /*HX    KMETA|',',    ???,        "tags-loop-continue",        */
  765. /*DT    KMETA|'-',    ???,        "negative-argument",        */
  766.     KMETA|'>',    gotoeob,    "end-of-buffer",
  767. /*MU    KMETA|'=',    ???,        "count-lines-region",        */
  768.     KMETA|'<',    gotobob,    "beginning-of-buffer",
  769. /*TT    KMETA|'@',    ???,        "mark-word",            */
  770. /*MU    KMETA|'[',    ???,        "backward-paragraph",        */
  771. /*TT    KMETA|'\\',    ???,        "delete-horizontal-space",    */
  772. /*MU    KMETA|']',    ???,        "forward-paragraph",        */
  773. /*TT    KMETA|'^',    ???,        "delete-indentation",        */
  774. /*MU    KMETA|'A',    ???,        "backward-sentence",        */
  775.     KMETA|'B',    backword,    "backward-word",
  776.     KMETA|'C',    capword,    "capitalize-word",
  777.     KMETA|'D',    delfword,    "kill-word",
  778. /*MU    KMETA|'E',    ???,        "forward-sentence",        */
  779.     KMETA|'F',    forwword,    "forward-word",
  780. /*HT    KMETA|'G',    ???,        "fill-region",            */
  781. /*MU    KMETA|'H',    ???,        "mark-paragraph",        */
  782. /*DMX    KMETA|'I',    ???,        "tab-to-tab-stop",        */
  783. /*MU    KMETA|'J',    ???,        "indent-new-comment-line",    */
  784.     KMETA|'L',    lowerword,    "downcase-word",
  785. /*EU    KMETA|'M',    ???,        "back-to-indentation",        */
  786. /*HT    KMETA|'Q',    ???,        "fill-paragraph",        */
  787.     KMETA|'R',    reposition,    "move-to-window-line",
  788. /*ET    KMETA|'T',    ???,        "transpose-words",        */
  789.     KMETA|'U',    upperword,    "upcase-word",
  790.     KMETA|'V',    backpage,    "scroll-down",
  791.     KMETA|'W',    copyregion,    "copy-region-as-kill",
  792.     KMETA|'X',    extend,        "execute-extended-command",
  793. /*HDX    KMETA|'Y',    ???,        "yank-pop",            */
  794. /*MU    KMETA|'Z',    ???,        "zap-to-char",            */
  795. /*HT    KMETA|'|',    ???,        "shell-command-on-region",    */
  796.     KMETA|'~',    notmodified,    "not-modified",
  797.     KMETA|DEL,    delbword,    "backward-kill-word",
  798.  
  799.     /*
  800.     ** These are unbound functions, callable by name.
  801.     ** They are GNU compatible (to various degrees).
  802.     */
  803.  
  804.  
  805. /*    -1,        ???,        "append-next-kill",    */
  806. /*    -1,        ???,        "apropos",        */
  807.     -1,        wallchart,    "describe-bindings",
  808. /*MT    -1,        ???,        "digit-argument",    */
  809.     -1,        showversion,    "emacs-version",
  810.     -1,        bindtokey,    "global-set-key",
  811.     -1,        gotoline,    "goto-line",
  812.     -1,        quit,        "kill-emacs",
  813.     -1,        backsearch,    "search-backward",
  814.     -1,        forwsearch,    "search-forward",
  815.     -1,        selfinsert,    "self-insert-command",
  816.     -1,        filename,    "set-visited-file-name",
  817.  
  818.     /* These are duplicate names for GNU compatible functions,
  819.     ** or incompatible commands I've left lying around for now.
  820.     ** The old command names get used as args to keydup() in the
  821.     ** various tty/xxx/ttykbd.c modules for function keys.
  822.     */
  823.  
  824.     -1,        backchar,    "back-char",
  825.     -1,        backline,    "back-line",
  826.     -1,        backpage,    "back-page",
  827.     -1,        prevwind,    "back-window",    
  828.     -1,        mvdnwind,    "down-window",
  829.     -1,        enlargewind,    "enlarge-window",
  830.     -1,        ctlxe,        "execute-macro",
  831.     -1,        forwchar,    "forw-char",
  832.     -1,        forwline,    "forw-line",
  833.     -1,        forwpage,    "forw-page",
  834.     -1,        nextwind,    "forw-window",
  835.     -1,        help,        "help",
  836.     -1,        selfinsert,    "ins-self",
  837.     -1,        killregion,    "kill-region",
  838.     -1,        searchagain,    "search-again",
  839.     -1,        setmark,    "set-mark",
  840.     -1,        shrinkwind,    "shrink-window",
  841.     -1,        mvupwind,    "up-window",
  842.             /*MT incorrect behaviour */
  843.  
  844. };
  845.  
  846. #define    NKEY    (sizeof(key) / sizeof(key[0]))
  847.  
  848. /*
  849.  * Symbol table lookup.
  850.  * Return a pointer to the SYMBOL node, or NULL if
  851.  * the symbol is not found.
  852.  */
  853. SYMBOL    *
  854. symlookup(cp)
  855. register char    *cp;
  856. {
  857.     register SYMBOL    *sp;
  858.  
  859.     sp = symbol[symhash(cp)];
  860.     while (sp != NULL) {
  861.         if (strcmp(cp, sp->s_name) == 0)
  862.             return (sp);
  863.         sp = sp->s_symp;
  864.     }
  865.     return (NULL);
  866. }
  867.  
  868. /*
  869.  * Take a string, and compute the symbol table
  870.  * bucket number. This is done by adding all of the characters
  871.  * together, and taking the sum mod NSHASH. The string probably
  872.  * should not contain any GR characters; if it does the "*cp"
  873.  * may get a nagative number on some machines, and the "%"
  874.  * will return a negative number!
  875.  */
  876. symhash(cp)
  877. register char    *cp;
  878. {
  879.     register int    c;
  880.     register int    n;
  881.  
  882.     n = 0;
  883.     while ((c = *cp++) != 0)
  884.         n += c;
  885.     return (n % NSHASH);
  886. }
  887.  
  888. /*
  889.  * Build initial keymap. The funny keys
  890.  * (commands, odd control characters) are mapped using
  891.  * a big table and calls to "keyadd". The printing characters
  892.  * are done with some do-it-yourself handwaving. The terminal
  893.  * specific keymap initialization code is called at the
  894.  * very end to finish up. All errors are fatal.
  895.  */
  896. keymapinit()
  897. {
  898.     register SYMBOL    *sp;
  899.     register KEY    *kp;
  900.     register int    i;
  901.     register int    hash;
  902.  
  903.     for (i=0; i<NKEYS; ++i)
  904.         binding[i] = NULL;
  905.     for (kp = &key[0]; kp < &key[NKEY]; ++kp)
  906.         keyadd(kp->k_key, kp->k_funcp, kp->k_name);
  907.  
  908.     /* Multiple bindings of standard commands */
  909.  
  910. #ifdef DAVEB
  911.         keydup(KCTRL|'Z', "scroll-down");
  912. #endif
  913.     keydup(KCTLX|KCTRL|'G',    "keyboard-quit");
  914.     keydup(KMETA|KCTRL|'G',    "keyboard-quit");
  915.     keydup(KMETA|' ', "set-mark-command");
  916.  
  917.     /*
  918.      * Self insert should be in hash table already, bound to -1.
  919.      * Bind all printing chars without an explicit binding already.
  920.      */
  921.     if ((sp=symlookup("self-insert-command")) == NULL)
  922.         abort();
  923.     binding[ KCTRL|'I' ] = sp;
  924.     for ( i = ' ' ; i < DEL ; ++i ) {
  925.         if (binding[i] != NULL)
  926.             continue;
  927.         binding[i] = sp;
  928.         ++sp->s_nkey;
  929.     }
  930.  
  931.     ttykeymapinit();
  932. }
  933.  
  934. /*
  935.  * Create a new builtin function "name"
  936.  * with function "funcp". If the "new" is a real
  937.  * key, bind it as a side effect. All errors
  938.  * are fatal.
  939.  */
  940. keyadd(new, funcp, name)
  941. int    (*funcp)();
  942. char    *name;
  943. {
  944.     register SYMBOL    *sp;
  945.     register int    hash;
  946.  
  947.     if ((sp=(SYMBOL *)malloc(sizeof(SYMBOL))) == NULL)
  948.         abort();
  949.     hash = symhash(name);
  950.     sp->s_symp = symbol[hash];
  951.     symbol[hash] = sp;
  952.     sp->s_nkey = 0;
  953.     sp->s_name = name;
  954.     sp->s_funcp = funcp;
  955.     if (new >= 0) {                /* Bind this key.    */
  956.         if (binding[new] != NULL)
  957.             abort();
  958.         binding[new] = sp;
  959.         ++sp->s_nkey;
  960.     }
  961. }
  962.  
  963. /*
  964.  * Bind key "new" to the existing routine "name".
  965.  * If the routine doesn't exist, just give a warning.
  966.  * It's no error to rebind a key.
  967.  */
  968. keydup(new, name)
  969. register int    new;
  970. char        *name;
  971. {
  972.     register SYMBOL    *sp;
  973.  
  974.     if ( (sp=symlookup(name))==NULL )
  975.         return;
  976.  
  977.     if( new >= 0 )
  978.         binding[new] = sp;
  979.  
  980.     ++sp->s_nkey;
  981. }
  982. SHAR_EOF
  983. chmod +x 'gnusymbol.c'
  984. fi # end of overwriting check
  985. if test ! -d 'sys'
  986. then
  987.     mkdir 'sys'
  988. fi
  989. cd 'sys'
  990. if test ! -d 'sysv'
  991. then
  992.     mkdir 'sysv'
  993. fi
  994. cd 'sysv'
  995. if test -f 'Makefile'
  996. then
  997.     echo shar: will not over-write existing file "'Makefile'"
  998. else
  999. cat << \SHAR_EOF > 'Makefile'
  1000. # Makefile for MicroEMACS.
  1001. # Is there a better way to do the rebuilds, other than using
  1002. # the links?
  1003.  
  1004. SYS    = sysv
  1005. TTY    = ansi
  1006.  
  1007. CFLAGS    = -O
  1008.  
  1009. LIBS =
  1010.  
  1011. OBJ =    basic.o \
  1012.     buffer.o \
  1013.     cinfo.o \
  1014.     display.o \
  1015.     echo.o \
  1016.     extend.o \
  1017.     file.o \
  1018.     kbd.o \
  1019.     line.o \
  1020.     main.o \
  1021.     random.o \
  1022.     region.o \
  1023.     search.o \
  1024.     symbol.o \
  1025.     version.o \
  1026.     window.o \
  1027.     word.o \
  1028.     fileio.o \
  1029.     spawn.o \
  1030.     ttyio.o \
  1031.     tty.o \
  1032.     ttykbd.o
  1033.  
  1034. xemacs:        $(OBJ)
  1035.         cc -o xemacs $(OBJ) $(LIBS)
  1036.  
  1037. $(OBJ):        def.h sysdef.h ttydef.h
  1038.  
  1039. sysdef.h:    sys/$(SYS)/sysdef.h    # Update links, if needed.
  1040.         rm -f sysdef.h
  1041.         ln sys/$(SYS)/sysdef.h .
  1042.  
  1043. ttydef.h:    tty/$(TTY)/ttydef.h
  1044.         rm -f ttydef.h
  1045.         ln tty/$(TTY)/ttydef.h .
  1046.  
  1047. fileio.c:    sys/$(SYS)/fileio.c
  1048.         rm -f fileio.c
  1049.         ln sys/$(SYS)/fileio.c .
  1050.  
  1051. spawn.c:    sys/$(SYS)/spawn.c
  1052.         rm -f spawn.c
  1053.         ln sys/$(SYS)/spawn.c .
  1054.  
  1055. tty.c:        tty/$(TTY)/tty.c
  1056.         rm -f tty.c
  1057.         ln tty/$(TTY)/tty.c .
  1058.  
  1059. ttyio.c:    sys/$(SYS)/ttyio.c
  1060.         rm -f ttyio.c
  1061.         ln sys/$(SYS)/ttyio.c .
  1062.  
  1063. ttykbd.c:    tty/$(TTY)/ttykbd.c
  1064.         rm -f ttykbd.c
  1065.         ln tty/$(TTY)/ttykbd.c .
  1066. SHAR_EOF
  1067. chmod +x 'Makefile'
  1068. fi # end of overwriting check
  1069. if test -f 'fileio.c'
  1070. then
  1071.     echo shar: will not over-write existing file "'fileio.c'"
  1072. else
  1073. cat << \SHAR_EOF > 'fileio.c'
  1074. /*
  1075.  * Name:    MicroEMACS
  1076.  *         System V file I/O, differs from ultrix 
  1077.  *          only in lack of rename() system call.
  1078.  * Version:    0
  1079.  * Last edit:    17-Apr-86
  1080.  * By:        gonzo!daveb
  1081.  *        {sun, amdahl, mtxinu}!rtech!gonzo!daveb
  1082.  */
  1083. #include    "def.h"
  1084.  
  1085. static    FILE    *ffp;
  1086.  
  1087. /*
  1088.  * Open a file for reading.
  1089.  */
  1090. ffropen(fn)
  1091. char    *fn;
  1092. {
  1093.     if ((ffp=fopen(fn, "r")) == NULL)
  1094.         return (FIOFNF);
  1095.     return (FIOSUC);
  1096. }
  1097.  
  1098. /*
  1099.  * Open a file for writing.
  1100.  * Return TRUE if all is well, and
  1101.  * FALSE on error (cannot create).
  1102.  */
  1103. ffwopen(fn)
  1104. char    *fn;
  1105. {
  1106.     if ((ffp=fopen(fn, "w")) == NULL) {
  1107.         eprintf("Cannot open file for writing");
  1108.         return (FIOERR);
  1109.     }
  1110.     return (FIOSUC);
  1111. }
  1112.  
  1113. /*
  1114.  * Close a file.
  1115.  * Should look at the status.
  1116.  */
  1117. ffclose()
  1118. {
  1119.     fclose(ffp);
  1120.     return (FIOSUC);
  1121. }
  1122.  
  1123. /*
  1124.  * Write a line to the already
  1125.  * opened file. The "buf" points to the
  1126.  * buffer, and the "nbuf" is its length, less
  1127.  * the free newline. Return the status.
  1128.  * Check only at the newline.
  1129.  */
  1130. ffputline(buf, nbuf)
  1131. register char    buf[];
  1132. {
  1133.     register int    i;
  1134.  
  1135.     for (i=0; i<nbuf; ++i)
  1136.         putc(buf[i]&0xFF, ffp);
  1137.     putc('\n', ffp);
  1138.     if (ferror(ffp) != FALSE) {
  1139.         eprintf("Write I/O error");
  1140.         return (FIOERR);
  1141.     }
  1142.     return (FIOSUC);
  1143. }
  1144.  
  1145. /*
  1146.  * Read a line from a file, and store the bytes
  1147.  * in the supplied buffer. Stop on end of file or end of
  1148.  * line. Don't get upset by files that don't have an end of
  1149.  * line on the last line; this seem to be common on CP/M-86 and
  1150.  * MS-DOS (the suspected culprit is VAX/VMS kermit, but this
  1151.  * has not been confirmed. If this is sufficiently researched
  1152.  * it may be possible to pull this kludge). Delete any CR
  1153.  * followed by an LF. This is mainly for runoff documents,
  1154.  * both on VMS and on Ultrix (they get copied over from
  1155.  * VMS systems with DECnet).
  1156.  */
  1157. ffgetline(buf, nbuf)
  1158. register char    buf[];
  1159. {
  1160.     register int    c;
  1161.     register int    i;
  1162.  
  1163.     i = 0;
  1164.     for (;;) {
  1165.         c = getc(ffp);
  1166.         if (c == '\r') {        /* Delete any non-stray    */
  1167.             c = getc(ffp);        /* carriage returns.    */
  1168.             if (c != '\n') {
  1169.                 if (i >= nbuf-1) {
  1170.                     eprintf("File has long line");
  1171.                     return (FIOERR);
  1172.                 }
  1173.                 buf[i++] = '\r';
  1174.             }
  1175.         }
  1176.         if (c==EOF || c=='\n')        /* End of line.        */
  1177.             break;
  1178.         if (i >= nbuf-1) {
  1179.             eprintf("File has long line");
  1180.             return (FIOERR);
  1181.         }
  1182.         buf[i++] = c;
  1183.     }
  1184.     if (c == EOF) {                /* End of file.        */
  1185.         if (ferror(ffp) != FALSE) {
  1186.             eprintf("File read error");
  1187.             return (FIOERR);
  1188.         }
  1189.         if (i == 0)            /* Don't get upset if    */
  1190.             return (FIOEOF);    /* no newline at EOF.    */
  1191.     }
  1192.     buf[i] = 0;
  1193.     return (FIOSUC);
  1194. }
  1195.  
  1196. /*
  1197.  * Rename the file "fname" into a backup
  1198.  * copy. On Unix the backup has the same name as the
  1199.  * original file, with a "~" on the end; this seems to
  1200.  * be newest of the new-speak. The error handling is
  1201.  * all in "file.c". The "unlink" is perhaps not the
  1202.  * right thing here; I don't care that much as
  1203.  * I don't enable backups myself.
  1204.  */
  1205. fbackupfile(fname)
  1206. char    *fname;
  1207. {
  1208.     register char    *nname;
  1209.  
  1210.     if ((nname=malloc(strlen(fname)+1+1)) == NULL)
  1211.         return (ABORT);
  1212.     (void) strcpy(nname, fname);
  1213.     (void) strcat(nname, "~");
  1214.     (void) unlink(nname);            /* Ignore errors.    */
  1215.  
  1216.     /* no rename on System V, so do it dangerous way. */
  1217.     if ( link(fname, nname) < 0 || unlink(fname) < 0 ) {
  1218.         free(nname);
  1219.         return (FALSE);
  1220.     }
  1221.     free(nname);
  1222.     return (TRUE);
  1223. }
  1224.  
  1225. /*
  1226.  * The string "fn" is a file name.
  1227.  * Perform any required case adjustments. All sustems
  1228.  * we deal with so far have case insensitive file systems.
  1229.  * We zap everything to lower case. The problem we are trying
  1230.  * to solve is getting 2 buffers holding the same file if
  1231.  * you visit one of them with the "caps lock" key down.
  1232.  * On UNIX file names are dual case, so we leave
  1233.  * everything alone.
  1234.  */
  1235. adjustcase(fn)
  1236. register char    *fn;
  1237. {
  1238. #if    0
  1239.     register int    c;
  1240.  
  1241.     while ((c = *fn) != 0) {
  1242.         if (c>='A' && c<='Z')
  1243.             *fn = c + 'a' - 'A';
  1244.         ++fn;
  1245.     }
  1246. #endif
  1247. }
  1248. SHAR_EOF
  1249. chmod +x 'fileio.c'
  1250. fi # end of overwriting check
  1251. if test -f 'spawn.c'
  1252. then
  1253.     echo shar: will not over-write existing file "'spawn.c'"
  1254. else
  1255. cat << \SHAR_EOF > 'spawn.c'
  1256. /*
  1257.  * Name:    MicroEMACS
  1258.  *        Spawn CLI for System V.
  1259.  * Version:    0
  1260.  * Last edit:    17-Apr-86
  1261.  * By:        gonzo!daveb
  1262.  *        {sun, amdahl, mtxinu}!rtech!daveb
  1263.  *
  1264.  * Spawn for System V.
  1265.  */
  1266. #include    "def.h"
  1267.  
  1268. #include    <signal.h>
  1269.  
  1270. char    *shellp    = NULL;            /* Saved "SHELL" program.    */
  1271. char    *shname = NULL;            /* Saved shell name        */
  1272.  
  1273. extern    char    *getenv();
  1274.  
  1275. /*
  1276.  * On System V, we no gots job control, so always run
  1277.  * a subshell using fork/exec. Bound to "C-C", and used
  1278.  * as a subcommand by "C-Z". (daveb)
  1279.  *
  1280.  * Returns 0 if the shell executed OK, something else if
  1281.  * we couldn't start shell or it exited badly.
  1282.  */
  1283. spawncli(f, n, k)
  1284. {
  1285.     extern char    *strrchr();
  1286.     register int    pid;
  1287.     register int    wpid;
  1288.     register int    (*oqsig)();
  1289.     register int    (*oisig)();
  1290.     int        status;
  1291.     int        errp = FALSE;
  1292.  
  1293.     if (shellp == NULL) {
  1294.         shellp = getenv("SHELL");
  1295.         if (shellp == NULL)
  1296.             shellp = getenv("shell");
  1297.         if (shellp == NULL)
  1298.             shellp = "/bin/sh";    /* Safer.        */
  1299.         shname = strrchr( shellp, '/' ); 
  1300.         shname = shname ? shname++ : shellp;
  1301.         
  1302.     }
  1303.     ttcolor(CTEXT);
  1304.     ttnowindow();
  1305.     ttmove(nrow-1, 0);
  1306.     if (epresf != FALSE) {
  1307.         tteeol();
  1308.         epresf = FALSE;
  1309.     }
  1310.     ttclose();
  1311.     sgarbf = TRUE;                /* Force repaint.    */
  1312.     oqsig = signal(SIGQUIT, SIG_IGN);
  1313.     oisig = signal(SIGINT,  SIG_IGN);
  1314.     if ((pid=fork()) == 0) {
  1315.         execlp(shellp, shname, "-i", NULL);
  1316.         _exit(1);            /* Should do better!    */
  1317.     }
  1318.     else if (pid > 0) {
  1319.         while ((wpid=wait(&status))>=0 && wpid!=pid)
  1320.             ;
  1321.     }
  1322.     else errp = TRUE;
  1323.  
  1324.     signal(SIGINT,  oisig);
  1325.     ttopen();
  1326.     if(errp)
  1327.         eprintf("Failed to create process");
  1328.  
  1329.     return ( errp | status );
  1330. }
  1331. SHAR_EOF
  1332. chmod +x 'spawn.c'
  1333. fi # end of overwriting check
  1334. if test -f 'sysdef.h'
  1335. then
  1336.     echo shar: will not over-write existing file "'sysdef.h'"
  1337. else
  1338. cat << \SHAR_EOF > 'sysdef.h'
  1339. /*
  1340.  * Name:    MicroEMACS
  1341.  *        Ultrix-32 system header file same for System V.
  1342.  * Version:    29
  1343.  * Last edit:    05-Feb-86
  1344.  * By:        rex::conroy
  1345.  *        decvax!decwrl!dec-rhea!dec-rex!conroy
  1346.  */
  1347. #define    PCC    1            /* "[]" gets an error.        */
  1348. #define    KBLOCK    8192            /* Kill grow.            */
  1349. #define    GOOD    0            /* Good exit status.        */
  1350.  
  1351. /*
  1352.  * Macros used by the buffer name making code.
  1353.  * Start at the end of the file name, scan to the left
  1354.  * until BDC1 (or BDC2, if defined) is reached. The buffer
  1355.  * name starts just to the right of that location, and
  1356.  * stops at end of string (or at the next BDC3 character,
  1357.  * if defined). BDC2 and BDC3 are mainly for VMS.
  1358.  */
  1359. #define    BDC1    '/'            /* Buffer names.        */
  1360. SHAR_EOF
  1361. chmod +x 'sysdef.h'
  1362. fi # end of overwriting check
  1363. if test -f 'ttyio.c'
  1364. then
  1365.     echo shar: will not over-write existing file "'ttyio.c'"
  1366. else
  1367. cat << \SHAR_EOF > 'ttyio.c'
  1368. /*
  1369.  * Name:    MicroEMACS
  1370.  *        System V terminal I/O.
  1371.  * Version:    0
  1372.  * Last edit:    17-Apr-86
  1373.  * By:        gonzo!daveb
  1374.  *        {sun, amdahl, mtxinu}!rtech!gonzo!daveb
  1375.  *
  1376.  * The functions in this file
  1377.  * negotiate with the operating system for
  1378.  * keyboard characters, and write characters to
  1379.  * the display in a barely buffered fashion.
  1380.  *
  1381.  * This version goes along with tty/termcap/tty.c.
  1382.  * Terminal size is determined there, rather than here, and
  1383.  * this does not open the termcap file
  1384.  */
  1385. #include    "def.h"
  1386.  
  1387. #include    <sys/types.h>
  1388. #include    <fcntl.h>
  1389. #include    <termio.h>
  1390.  
  1391. #define    NOBUF    512            /* Output buffer size.        */
  1392.  
  1393. char    obuf[NOBUF];            /* Output buffer.        */
  1394. int    nobuf;                /* buffer count            */
  1395.  
  1396. static struct termio    ot;        /* entry state of the terminal    */
  1397. static struct termio    nt;        /* editor's terminal state    */
  1398.  
  1399. static int ttyactivep = FALSE;        /* terminal in editor mode?    */
  1400. static int ttysavedp = FALSE;        /* terminal state saved?    */
  1401.  
  1402. int    nrow;                /* Terminal size, rows.        */
  1403. int    ncol;                /* Terminal size, columns.    */
  1404.  
  1405. /*
  1406.  * This function gets called once, to set up
  1407.  * the terminal channel.  This version turns off flow
  1408.  * control.  This may be wrong for your system, but no
  1409.  * good solution has really been found (daveb).
  1410.  */
  1411. ttopen()
  1412. {
  1413.     register char    *cp;
  1414.     extern char    *getenv();
  1415.  
  1416.     if (ttyactivep)
  1417.         return;
  1418.  
  1419.     if( !ttysavedp )
  1420.     {
  1421.         if (ioctl(0, TCGETA, &ot) < 0)
  1422.             abort();
  1423.         nt = ot;        /* save entry state        */
  1424.         nt.c_cc[VMIN] = 1;    /* one character read is OK    */
  1425.         nt.c_cc[VTIME] = 0;    /* Never time out.        */
  1426.         nt.c_iflag |= IGNBRK;
  1427.         nt.c_iflag &= ~( ICRNL | INLCR | ISTRIP | IXON | IXOFF );
  1428.         nt.c_oflag &= ~OPOST;
  1429.         nt.c_cflag |= CS8;    /* allow 8th bit on input    */
  1430.         nt.c_cflag &= ~PARENB;    /* Don't check parity        */
  1431.         nt.c_lflag &= ~( ECHO | ICANON | ISIG );
  1432.         ttysavedp = TRUE;
  1433.     }
  1434.     
  1435.     if (ioctl(0, TCSETAF, &nt) < 0)
  1436.         abort();
  1437.  
  1438.     /* This really belongs in tty/termcap... */
  1439.  
  1440.     if ((cp=getenv("TERMCAP")) == NULL
  1441.     || (nrow=getvalue(cp, "li")) <= 0
  1442.     || (ncol=getvalue(cp, "co")) <= 0) {
  1443.         nrow = 24;
  1444.         ncol = 80;
  1445.     }
  1446.     if (nrow > NROW)            /* Don't crash if the    */
  1447.         nrow = NROW;            /* termcap entry is    */
  1448.     if (ncol > NCOL)            /* too big.        */
  1449.         ncol = NCOL;
  1450.  
  1451.     ttyactivep = TRUE;
  1452. }
  1453.  
  1454. /*
  1455.  * This routine scans a string, which is
  1456.  * actually the return value of a getenv call for the TERMCAP
  1457.  * variable, looking for numeric parameter "name". Return the value
  1458.  * if found. Return -1 if not there. Assume that "name" is 2
  1459.  * characters long. This limited use of the TERMCAP lets us find
  1460.  * out the size of a window on the X display.
  1461.  */
  1462. getvalue(cp, name)
  1463. register char    *cp;
  1464. register char    *name;
  1465. {
  1466.     for (;;) {
  1467.         while (*cp!=0 && *cp!=':')
  1468.             ++cp;
  1469.         if (*cp++ == 0)            /* Not found.        */
  1470.             return (-1);
  1471.         if (cp[0]==name[0] && cp[1]==name[1] && cp[2]=='#')
  1472.             return (atoi(cp+3));    /* Stops on ":".    */
  1473.     }
  1474. }
  1475.  
  1476. /*
  1477.  * This function gets called just
  1478.  * before we go back home to the shell. Put all of
  1479.  * the terminal parameters back.
  1480.  */
  1481. ttclose()
  1482. {
  1483.     if(!ttysavedp || !ttyactivep)
  1484.         return;
  1485.     ttflush();
  1486.     if (ioctl(0, TCSETAF, &ot) < 0)
  1487.         abort();
  1488.     ttyactivep = FALSE;
  1489. }
  1490.  
  1491. /*
  1492.  * Write character to the display.
  1493.  * Characters are buffered up, to make things
  1494.  * a little bit more efficient.
  1495.  */
  1496. ttputc(c)
  1497. {
  1498.     if (nobuf >= NOBUF)
  1499.         ttflush();
  1500.     obuf[nobuf++] = c;
  1501. }
  1502.  
  1503. /*
  1504.  * Flush output.
  1505.  */
  1506. ttflush()
  1507. {
  1508.     if (nobuf != 0) {
  1509.         write(1, obuf, nobuf);
  1510.         nobuf = 0;
  1511.     }
  1512. }
  1513.  
  1514. /*
  1515.  * Read character from terminal.
  1516.  * All 8 bits are returned, so that you can use
  1517.  * a multi-national terminal.
  1518.  */
  1519. ttgetc()
  1520. {
  1521.     char    buf[1];
  1522.  
  1523.     while (read(0, &buf[0], 1) != 1)
  1524.         ;
  1525.     return (buf[0] & 0xFF);
  1526. }
  1527. SHAR_EOF
  1528. chmod +x 'ttyio.c'
  1529. fi # end of overwriting check
  1530. cd ..
  1531. cd ..
  1532. if test ! -d 'tty'
  1533. then
  1534.     mkdir 'tty'
  1535. fi
  1536. cd 'tty'
  1537. if test ! -d '7300'
  1538. then
  1539.     mkdir '7300'
  1540. fi
  1541. cd '7300'
  1542. if test -f 'tty.c'
  1543. then
  1544.     echo shar: will not over-write existing file "'tty.c'"
  1545. else
  1546. cat << \SHAR_EOF > 'tty.c'
  1547. /*
  1548.  * Name:    MicroEMACS
  1549.  *        AT&T UNIX PC 7300/3b1 terminal display
  1550.  * Version:    29
  1551.  * Last edit:    25-Apr-86
  1552.  * By:        {sun, amdahl, mtxinu, cbosgd}!rtech!daveb
  1553.  *
  1554.  * This is nearly the ansi/tty.c, except the 7300 has broken scroll
  1555.  * region support with index and reverse index.  Instead we do it
  1556.  * with parameterized insert/delete lines.
  1557.  *
  1558.  * It also has "smart" support for the window system.
  1559.  */
  1560. #include    "def.h"
  1561.  
  1562. #define    BEL    0x07            /* BEL character.        */
  1563. #define    ESC    0x1B            /* ESC character.        */
  1564. #define    LF    0x0A            /* Line feed.            */
  1565.  
  1566. extern    int    ttrow;
  1567. extern    int    ttcol;
  1568. extern    int    tttop;
  1569. extern    int    ttbot;
  1570. extern    int    tthue;
  1571.  
  1572. int    tceeol    =    3;        /* Costs, ANSI display.        */
  1573. int    tcinsl    =     17;
  1574. int    tcdell    =    16;
  1575.  
  1576. /*
  1577.  * Initialize the terminal when the editor
  1578.  * gets started up. This is a no-op on the ANSI
  1579.  * display.
  1580.  */
  1581. ttinit()
  1582. {
  1583. }
  1584.  
  1585. /*
  1586.  * Clean up the terminal, in anticipation of
  1587.  * a return to the command interpreter. This is a no-op
  1588.  * on the ANSI display. On the SCALD display, it sets the
  1589.  * window back to half screen scrolling. Perhaps it should
  1590.  * query the display for the increment, and put it
  1591.  * back to what it was.
  1592.  */
  1593. tttidy()
  1594. {
  1595. }
  1596.  
  1597. /*
  1598.  * Move the cursor to the specified
  1599.  * origin 0 row and column position. Try to
  1600.  * optimize out extra moves; redisplay may
  1601.  * have left the cursor in the right
  1602.  * location last time!
  1603.  */
  1604. ttmove(row, col)
  1605. {
  1606.     if (ttrow!=row || ttcol!=col) {
  1607.         ttputc(ESC);
  1608.         ttputc('[');
  1609.         asciiparm(row+1);
  1610.         ttputc(';');
  1611.         asciiparm(col+1);
  1612.         ttputc('H');
  1613.         ttrow = row;
  1614.         ttcol = col;
  1615.     }
  1616. }
  1617.  
  1618. /*
  1619.  * Erase to end of line.
  1620.  */
  1621. tteeol()
  1622. {
  1623.     ttputc(ESC);
  1624.     ttputc('[');
  1625.     ttputc('K');
  1626. }
  1627.  
  1628. /*
  1629.  * Erase to end of page.
  1630.  */
  1631. tteeop()
  1632. {
  1633.     ttputc(ESC);
  1634.     ttputc('[');
  1635.     ttputc('J');
  1636. }
  1637.  
  1638. /*
  1639.  * Make a noise.
  1640.  */
  1641. ttbeep()
  1642. {
  1643.     ttputc(BEL);
  1644.     ttflush();
  1645. }
  1646.  
  1647. /*
  1648.  * Convert a number to decimal
  1649.  * ascii, and write it out. Used to
  1650.  * deal with numeric arguments.
  1651.  */
  1652. asciiparm(n)
  1653. register int    n;
  1654. {
  1655.     register int    q;
  1656.  
  1657.     q = n/10;
  1658.     if (q != 0)
  1659.         asciiparm(q);
  1660.     ttputc((n%10) + '0');
  1661. }
  1662.  
  1663. /*
  1664.  * Insert a block of blank lines onto the
  1665.  * screen, using parameterized insert and delete line commands.
  1666.  *
  1667.  * Deal with the one
  1668.  * line case, which is a little bit special, with special
  1669.  * case code. Put all of the back index commands out
  1670.  * in a block. The SCALDstation loses the position
  1671.  * of the cursor.
  1672.  */
  1673. ttinsl(row, bot, nchunk)
  1674. {
  1675.     if (row == bot) {            /* Funny case.        */
  1676.         if (nchunk != 1)
  1677.             abort();
  1678.         ttmove(row, 0);
  1679.         tteeol();
  1680.     } else {                /* General case.    */
  1681.         ttwindow(row, bot);
  1682.  
  1683.         /* delete the lines that are going away */
  1684.         ttmove(bot + 1 - nchunk , 0);
  1685.         ttputc(ESC);
  1686.         ttputc('[');
  1687.         asciiparm( nchunk );
  1688.         ttputc('M');
  1689.  
  1690.         /* add the lines */
  1691.         ttmove(row, 0);
  1692.         ttputc(ESC);
  1693.         ttputc('[');
  1694.         asciiparm( nchunk );
  1695.         ttputc('L');
  1696.     }
  1697. }
  1698.  
  1699. /*
  1700.  * Delete a block of lines, with the uppermost
  1701.  * line at row "row", in a screen slice that extends to
  1702.  * row "bot". The "nchunk" is the number of lines that have
  1703.  * to be deleted. Watch for the pathalogical 1 line case.
  1704.  * Done using delete and insert line commands.
  1705.  */
  1706. ttdell(row, bot, nchunk)
  1707. {
  1708.     if (row == bot) {            /* Funny case.        */
  1709.         if (nchunk != 1)
  1710.             abort();
  1711.         ttmove(row, 0);
  1712.         tteeol();
  1713.     } else {                /* General case.    */
  1714.  
  1715.         /* delete the lines that are going away */
  1716.         ttmove(row, 0);
  1717.         ttputc(ESC);
  1718.         ttputc('[');
  1719.         asciiparm( nchunk );
  1720.         ttputc('M');
  1721.  
  1722.         /* insert new lines to fill the empty space */
  1723.         ttmove(bot + 1 - nchunk , 0);
  1724.         ttputc(ESC);
  1725.         ttputc('[');
  1726.         asciiparm( nchunk );
  1727.         ttputc('L');
  1728.  
  1729.     }
  1730. }
  1731.  
  1732. /*
  1733.  * This routine sets the scrolling window
  1734.  * on the display to go from line "top" to line
  1735.  * "bot" (origin 0, inclusive). The caller checks
  1736.  * for the pathalogical 1 line scroll window that
  1737.  * doesn't work right, and avoids it. The "ttrow"
  1738.  * and "ttcol" variables are set to a crazy value
  1739.  * to ensure that the next call to "ttmove" does
  1740.  * not turn into a no-op (the window adjustment
  1741.  * moves the cursor).
  1742.  */
  1743. ttwindow(top, bot)
  1744. {
  1745.     /* No-op on 7300 */
  1746. }
  1747.  
  1748. /*
  1749.  * Switch to full screen scroll. This is
  1750.  * used by "spawn.c" just before is suspends the
  1751.  * editor, and by "display.c" when it is getting ready
  1752.  * to exit. This function gets to full screen scroll
  1753.  * by sending a DECSTBM with default parameters, but
  1754.  * I think that this is wrong. The SRM seems to say
  1755.  * that the default for Pb is 24, not the size of the
  1756.  * screen, which seems really dumb. Do I really have
  1757.  * to read the size of the screen as in "ttresize"
  1758.  * to do this right?
  1759.  */
  1760. ttnowindow()
  1761. {
  1762.     /* No-op on 7300 */
  1763. }
  1764.  
  1765. /*
  1766.  * Set the current writing color to the
  1767.  * specified color. Watch for color changes that are
  1768.  * not going to do anything (the color is already right)
  1769.  * and don't send anything to the display.
  1770.  * The rainbow version does this in putline.s on a
  1771.  * line by line basis, so don't bother sending
  1772.  * out the color shift.
  1773.  */
  1774. ttcolor(color)
  1775. register int    color;
  1776. {
  1777.     if (color != tthue) {
  1778.         if (color == CTEXT) {        /* Normal video.    */
  1779.             ttputc(ESC);
  1780.             ttputc('[');
  1781.             ttputc('m');
  1782.         } else if (color == CMODE) {    /* Reverse video.    */
  1783.             ttputc(ESC);
  1784.             ttputc('[');
  1785.             ttputc('7');
  1786.             ttputc('m');
  1787.         }
  1788.         tthue = color;            /* Save the color.    */
  1789.     }
  1790. }
  1791.  
  1792. /*
  1793.  * This routine is called by the
  1794.  * "refresh the screen" command to try and resize
  1795.  * the display. The new size, which must be deadstopped
  1796.  * to not exceed the NROW and NCOL limits, it stored
  1797.  * back into "nrow" and "ncol". Display can always deal
  1798.  * with a screen NROW by NCOL. Look in "window.c" to
  1799.  * see how the caller deals with a change.
  1800.  */
  1801. ttresize()
  1802. {
  1803. # if 0
  1804.     register int    c;
  1805.     register int    newnrow;
  1806.     register int    newncol;
  1807.  
  1808.     else if (newnrow > NROW)
  1809.         newnrow = NROW;
  1810.     if (newncol < 1)
  1811.         newncol = 1;
  1812.     else if (newncol > NCOL)
  1813.         newncol = NCOL;
  1814.     nrow = newnrow;
  1815.     ncol = newncol;
  1816. # endif
  1817. }
  1818. SHAR_EOF
  1819. chmod +x 'tty.c'
  1820. fi # end of overwriting check
  1821. if test -f 'ttydef.h'
  1822. then
  1823.     echo shar: will not over-write existing file "'ttydef.h'"
  1824. else
  1825. cat << \SHAR_EOF > 'ttydef.h'
  1826. /*
  1827.  * Name:    MicroEMACS
  1828.  *        AT&T UNIX PC 7300/3b1 terminal header file.
  1829.  * Version:    29
  1830.  * Last edit:    05-Feb-86
  1831.  * By:        rex::conroy
  1832.  *        decvax!decwrl!dec-rhea!dec-rex!conroy
  1833.  */
  1834. #define    GOSLING    1            /* Compile in fancy display.    */
  1835. #define    MEMMAP    0            /* Not memory mapped video.    */
  1836.  
  1837. /*
  1838.  * 7300 Maximums.
  1839.  */
  1840. #define    NROW    25            /* Rows.            */
  1841. #define    NCOL    80            /* Columns.            */
  1842. SHAR_EOF
  1843. chmod +x 'ttydef.h'
  1844. fi # end of overwriting check
  1845. if test -f 'ttykbd.c'
  1846. then
  1847.     echo shar: will not over-write existing file "'ttykbd.c'"
  1848. else
  1849. cat << \SHAR_EOF > 'ttykbd.c'
  1850. /*
  1851.  * Name:    MicroEMACS
  1852.  *         AT&T UNIX PC 7300/3b1 terminal keyboard.
  1853.  * Version:    29
  1854.  * Last edit:    25-Apr-86
  1855.  * By:        {sun, amdahl, mtxinu, cbosgd}!rtech!daveb
  1856.  *
  1857.  * This is presently a vanilla implementation, but may in time
  1858.  * support function keys and mouse mapping.
  1859.  */
  1860. #include    "def.h"
  1861.  
  1862. /*
  1863.  * Names for the keys with basic keycode
  1864.  * between KFIRST and KLAST (inclusive). This is used by
  1865.  * the key name routine in "kbd.c".
  1866.  *
  1867.  * It is presently unimplemented on the 7300 (daveb).
  1868.  */
  1869. char    *keystrings[] = {
  1870.  
  1871.     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  1872.     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  1873.     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  1874.     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
  1875. };
  1876.  
  1877.  
  1878. /*
  1879.  * Read in a key, doing the low level mapping
  1880.  * of ASCII code to 11 bit code.
  1881.  */
  1882. getkbd()
  1883. {
  1884.     register int    c;
  1885.     register int    n;
  1886.  
  1887.     c = ttgetc();
  1888.     if (c == Esc) {
  1889.         c = ttgetc();
  1890.         if (ISLOWER(c) != FALSE)    /* Copy the standard    */
  1891.             c = TOUPPER(c);        /* META code.        */
  1892.         if (c>=0x00 && c<=0x1F)
  1893.             c = KCTRL | (c+'@');
  1894.         return (KMETA | c);
  1895.     }
  1896.     return (c);
  1897. }
  1898.  
  1899.  
  1900. /*
  1901.  * Terminal specific keymap initialization.
  1902.  */
  1903. ttykeymapinit()
  1904. {
  1905. }
  1906. SHAR_EOF
  1907. chmod +x 'ttykbd.c'
  1908. fi # end of overwriting check
  1909. cd ..
  1910. cd ..
  1911. #    End of shell archive
  1912. exit 0
  1913.  
  1914. ------------------------------
  1915.  
  1916. End of Digest
  1917. ******************************
  1918.